<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改用户名</title>
<script src="libs/jquery-1.12.1.min.js"></script>
<link href="libs/css/bootstrap.min.css" rel="stylesheet">
<script src="libs/bootstrap.min.js"></script>
<script type="text/javascript" src="libs/jquery.backstretch.min.js"></script>

</head>
<body>
<nav class="navbar navbar-default">
	<div class="container-fluid">
		<!-- Brand and toggle get grouped for better mobile display -->
		<div class="navbar-header">
			<a class="navbar-brand" href="#">用户 _<span id="nickname"></span></a>
		</div>

		<!-- Collect the nav links, forms, and other content for toggling -->
		<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
	      <ul class="nav navbar-nav">
	        <li ><a href="homepage.html">首页 <span class="sr-only">(current)</span></a></li>
	        <li><a href="#">Link2</a></li>
	        <li class="dropdown">
	          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">档案管理 <span class="caret"></span></a>
	          <ul class="dropdown-menu">
	            <li><a href="archiveadd.html">添加档案</a></li>
	            <li><a href="#">删除档案 </a></li>
	            <li role="separator" class="divider"></li>
	            <li><a href="archivequery.html">查看档案</a></li>
	            <li role="separator" class="divider"></li>
	            <li><a href="#">One more separated link</a></li>
	          </ul>
	        </li>
	      </ul>
	      
	      <form class="navbar-form navbar-left" role="search">
	        <div class="form-group">
	          <input type="text" class="form-control" placeholder="档案号或者ID" id="arc_id">
	        <button type="submit" class="btn btn-default" id="hpbut">查询</button>
	        </div>
	      </form>
	      
	      <ul class="nav navbar-nav navbar-right">
	        <li><a href="#">Link3</a></li>
	        <li class="dropdown" >
	          <a href="#"  class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">用户操作 <span class="caret"></span></a>
	          <ul class="dropdown-menu">
	            <li><a href="#">更换用户名</a></li>
	            <li role="separator" class="divider"></li>
	            <li><button type="button" class="btn btn-link" id="quit">用户退出</button></li>
	          </ul>
	        </li>
	      </ul>
		</div><!-- /.navbar-collapse -->
	</div><!-- /.container-fluid -->
</nav>
<div class="container">
	<div class="row" style="padding-top: 150px">
		<div class="col-lg-2 col-lg-offset-5" >
			<div  >
				<label for="nickname" style="color: white">当前用户名:</label>
				<span id="nickname1" style="color: white"></span>
							
			</div>
			<div class="form-group" >
				<label for="nickname2" style="color: white">新用户名</label>
				<input type="text" class="form-control" id="nickname2" >			
			</div>
				<input type="button" class="btn  btn-block" id="updatenn" value="修改">
		</div>	
	</div>
</div>
<script type="text/javascript">
$.backstretch("picture/3.jpg")
</script>
<script type="text/javascript">
function getnickname(){
	$.getJSON('querynn.action',function(res){
		$('#nickname').text(res.nickname);
		$('#nickname1').text(res.nickname);
	});
};
$(function (){
	getnickname();
	$('#updatenn').click(function(){
		$.post('updatenn.action',{
			nickname : $('#nickname2').val()
		},function(res){
			console.log(res);
			if("OK"==res){
				getnickname();
				alert('that’s ok');
				
			}
		});
	});
	$('#quit').click(function(){
		$.post('quit.action',{
		},function(res){
			if("quit"==res){window.location.href='login.html';}
		});
	});
});
</script>
</body>
</html>